﻿Namespace PL.CoreSDK
    Public Class SOPAttribute_PL
        Inherits PLBase

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
        End Sub
        Public Sub New()
            MyBase.New()
        End Sub
        Public Overrides Function Delete() As Boolean
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            Return True
        End Function

        Public Shared Function GetSOPAttributeByID(ByVal id As Guid) As DataRow
            Return MetaQuery.GetDataById("SOPAttribute", id)
        End Function

        Public Shared Sub SaveAttributeDocument(ByVal sopAttributeId As Guid, ByVal text As String, ByVal imageStream As IO.MemoryStream)
            Dim sqlcmd As System.Data.SqlClient.SqlCommand = Nothing

            sqlcmd = MetaQuery.GetSPCmdByMetaName("SOPAttributeDocument_PL_Save")
            sqlcmd.Parameters("@SOPAttributeId").Value = sopAttributeId
            sqlcmd.Parameters("@DocumentData").Value = text
            If imageStream IsNot Nothing Then 'imagestream est utiliser quand on sauve le diagram
                sqlcmd.Parameters("@BinaryImage").Value = imageStream.ToArray
            End If
            sqlcmd.ExecuteNonQuery()
            sqlcmd.Dispose()
        End Sub
    End Class
End Namespace
